package com.作业.Day17;


public class Homework3 {
    public static void main(String[] args) {
        Thread younger = new Thread(new ClimbThread(), "年轻人");
        Thread older = new Thread(new ClimbThread(), "老年人");
        younger.start();
        older.start();
    }
}
class ClimbThread implements Runnable{

    @Override
    public void run() {
        for(int i=0;i<10;i++){
            System.out.println(Thread.currentThread().getName()+"爬完100米");
            if(Thread.currentThread().getName().equals("年轻人")) {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            else if(Thread.currentThread().getName().equals("老年人")) {
                try {
                    Thread.sleep(150);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }
        System.out.println(Thread.currentThread().getName()+"到达终点");


    }
}

